package com.ruoyi.openDoor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.openDoor.domain.BusinessRoomDuration;
import com.ruoyi.openDoor.service.IBusinessRoomDurationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商家的包间的时长Controller
 * 
 * @author ruoyi
 * @date 2023-02-06
 */
@RestController
@RequestMapping("/system/duration")
public class BusinessRoomDurationController extends BaseController
{
    @Autowired
    private IBusinessRoomDurationService businessRoomDurationService;

    /**
     * 查询商家的包间的时长列表
     */
    @PreAuthorize("@ss.hasPermi('system:duration:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessRoomDuration businessRoomDuration)
    {
        startPage();
        List<BusinessRoomDuration> list = businessRoomDurationService.selectBusinessRoomDurationList(businessRoomDuration);
        return getDataTable(list);
    }

    /**
     * 导出商家的包间的时长列表
     */
    @PreAuthorize("@ss.hasPermi('system:duration:export')")
    @Log(title = "商家的包间的时长", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinessRoomDuration businessRoomDuration)
    {
        List<BusinessRoomDuration> list = businessRoomDurationService.selectBusinessRoomDurationList(businessRoomDuration);
        ExcelUtil<BusinessRoomDuration> util = new ExcelUtil<BusinessRoomDuration>(BusinessRoomDuration.class);
        util.exportExcel(response, list, "商家的包间的时长数据");
    }

    /**
     * 获取商家的包间的时长详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:duration:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(businessRoomDurationService.selectBusinessRoomDurationById(id));
    }

    /**
     * 新增商家的包间的时长
     */
    @PreAuthorize("@ss.hasPermi('system:duration:add')")
    @Log(title = "商家的包间的时长", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessRoomDuration businessRoomDuration)
    {
        return toAjax(businessRoomDurationService.insertBusinessRoomDuration(businessRoomDuration));
    }

    /**
     * 修改商家的包间的时长
     */
    @PreAuthorize("@ss.hasPermi('system:duration:edit')")
    @Log(title = "商家的包间的时长", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessRoomDuration businessRoomDuration)
    {
        return toAjax(businessRoomDurationService.updateBusinessRoomDuration(businessRoomDuration));
    }

    /**
     * 删除商家的包间的时长
     */
    @PreAuthorize("@ss.hasPermi('system:duration:remove')")
    @Log(title = "商家的包间的时长", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(businessRoomDurationService.deleteBusinessRoomDurationByIds(ids));
    }
}
